package com.smartrm.trade.domain.event;

import com.smartrm.globalinfrcore.event.DomainEvent;
import com.smartrm.trade.domain.OrderDO;
import com.smartrm.trade.domain.OrderType;
import com.smartrm.trade.domain.valueobject.StockedCommodityVOJ;

import java.math.BigDecimal;
import java.util.List;

/*
 * @program: common-starters
 * @description: 订单成功完成事件
 * @author: houhong
 * @create: 2023-01-11 15:09
 */
public class OrderSuccessedEvent extends DomainEvent {

    private long machineId;
    private long orderId;
    private OrderType type;
    private BigDecimal totalAmount;
    private List<StockedCommodityVOJ> commodities;

    public OrderSuccessedEvent(OrderDO order) {
        super("trade.OrderSucceededEvent");
        machineId = order.getMachineId();
        orderId = order.getOrderId();
        type = order.getType();
        totalAmount = order.totalAmount();
        commodities = order.getCommodities();
    }

    public long getMachineId() {
        return machineId;
    }

    public void setMachineId(long machineId) {
        this.machineId = machineId;
    }

    public long getOrderId() {
        return orderId;
    }

    public void setOrderId(long orderId) {
        this.orderId = orderId;
    }

    public OrderType getType() {
        return type;
    }

    public void setType(OrderType type) {
        this.type = type;
    }

    public BigDecimal getTotalAmount() {
        return totalAmount;
    }

    public void setTotalAmount(BigDecimal totalAmount) {
        this.totalAmount = totalAmount;
    }

    public List<StockedCommodityVOJ> getCommodities() {
        return commodities;
    }

    public void setCommodities(
            List<StockedCommodityVOJ> commodities) {
        this.commodities = commodities;
    }

    @Override
    public String key() {
        return Long.toString(machineId);
    }
}